/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


/**
 *
 * @author TrongKhoa
 */
public class MyConnectionString
{

    public String _ServerIP;
    public String _ServerPort;
    public String _DatabaseName;
    public String _UserName;
    public String _Password;

    public MyConnectionString(String _ServerIP, String _ServerPort, String _DatabaseName, String _UserName, String _Password)
    {
        this._ServerIP = _ServerIP;
        this._ServerPort = _ServerPort;
        this._DatabaseName = _DatabaseName;
        this._UserName = _UserName;
        this._Password = _Password;
    }

    public MyConnectionString(String con) throws Exception
    {
        String[] data = con.split(";");
        if (data.length != 5)
        {
            throw new Exception("Connection ko hợp lệ");
        }
        _ServerIP = data[0];
        _ServerPort = data[1];
        _DatabaseName = data[2];
        _UserName = data[3];
        _Password = data[4];
    }

    public String GetConnectionString()
    {
        return String.format("%s;%s;%s;%s;%s", _ServerIP, _ServerPort,_DatabaseName, _UserName, _Password);
    }
}
